package Thread;
//线程终止
public class Demo9 {
        public static void main(String[] args) {

            Thread t=new Thread(()->{
                while (Thread.currentThread().isInterrupted()){
                    System.out.println("线程工作中");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println("线程工作完毕");
            });
            t.start();
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("让t线程终止");
           t.interrupt();
        }
    }


